﻿//using System;
//using System.Collections.Generic;
//using System.Runtime.InteropServices;
//using System.Text;

//namespace YiSha.Util.SystemResourceMonitor
//{
//    public class RAMMonitor
//    {
//        [DllImport("kernel32")]
//        public static extern void GlobalMemoryStatus(ref Memory32Info meminfo);
//        [DllImport("kernel64")]
//        public static extern void GlobalMemoryStatus(ref Memory64Info meminfo);
//        public static object GetRAMInfo()
//        {
//            if (RuntimeInformation.OSArchitecture.ToString() == "X64")
//            {
//                Memory64Info MemInfo = new Memory64Info();
//                GlobalMemoryStatus(ref MemInfo);

//                MemoryInfo MemInfo = new MemoryInfo();
//                GlobalMemoryStatus(ref MemInfo);

//                double totalMb = MemInfo.TotalPhysical / 1024 / 1024;
//                double avaliableMb = MemInfo.AvailablePhysical / 1024 / 1024;

//                Console.WriteLine($"物理内存共有:{totalMb}MB");
//                Console.WriteLine($"可使用的物理内存:{avaliableMb}MB");
//                Console.WriteLine($"剩余内存百分比：{Math.Round((avaliableMb / totalMb) * 100, 2)}");
//        }
//    }
//    /// <summary>
//    /// 32位
//    /// </summary>
//    public struct Memory32Info
//    {
//        public uint Length;
//        public uint MemoryLoad;
//        public ulong TotalPhysical;//总内存
//        public ulong AvailablePhysical;//可用物理内存
//        public ulong TotalPageFile;
//        public ulong AvailablePageFile;
//        public ulong TotalVirtual;
//        public ulong AvailableVirtual;
//    }

//    /// <summary>
//    /// 64位
//    /// </summary>
//    public struct Memory64Info
//    {
//        public uint Length;
//        public uint MemoryLoad;
//        public uint TotalPhysical;//总内存
//        public uint AvailablePhysical;//可用物理内存
//        public uint TotalPageFile;
//        public uint AvailablePageFile;
//        public uint TotalVirtual;
//        public uint AvailableVirtual;
//    }
//}
